package com.example.chapter2.dao;

import com.example.chapter2.entity.User;
import org.apache.ibatis.annotations.*;


@Mapper
public interface UserDao2 {
    @Results(id = "userMap",value = {
        @Result(property = "name",column = "username"),
        @Result(property = "sex",column = "sex"),
        @Result(property = "password",column = "password")
    })
    @Select("select * from user where username = #{username} and password = #{password}")
    User getUserByName(@Param("username") String name, String password);

    @Insert("insert into user(username,password,sex) values (#{name},#{password},#{sex})")
    int creatUser(User user);
    @Update("update user set password = #{password}, sex = #{sex} where username = #{name}")
    int updateUser(User user);

    @Delete("delete from user where username = #{username}")
    int deleteUser(@Param("username") String name);
}
